package reviewAlgorithms.dynamicProgramming;

public class UniquePaths {
    public static void main(String[] args) {
        System.out.println(uniquePaths(3,2));
    }
    public static int uniquePaths(int m, int n) {
        if (m < 1 || n < 1){
            return 0;
        }
        int[][] dp = new int[m][n];
        dp[0][0] = 1;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i - 1 < 0 && j - 1 >= 0){
                    dp[i][j] = dp[i][j - 1];
                }
                if (i - 1 >= 0 && j - 1 >= 0){
                    dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
                }
                if (i - 1 >= 0 && j - 1 < 0){
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
        return dp[m - 1][n - 1];
    }
}
